package com.tengju.bff.infrastructure.export.repo;

import com.tengju.bff.infrastructure.export.convert.TableVoConvert;
import com.tengju.bff.interfaces.manage.crm.brand.facade.BrandMarketSortFacade;
import com.tengju.bff.interfaces.manage.crm.brand.form.BrandMarketSortSECQueryForm;
import com.tengju.bff.interfaces.shared.TableVO;
import com.tengju.bff.interfaces.shared.export.BrandMarketSecExportQuery;
import com.tengju.export.domain.record.ExportDataSourceRepository;
import com.tengju.export.domain.record.Query;
import com.tengju.export.domain.record.Table;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: 李大仙
 * @date: 2021/8/23 2:39 下午
 */
@Service("brandMarketSecExportDataSourceRepository")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class BrandMarketSecExportDataSourceRepository implements ExportDataSourceRepository {

    private final BrandMarketSortFacade brandMarketSortFacade;

    @Override
    public Table batchFindDataSource(Query query) {
        BrandMarketSecExportQuery exportQuery = (BrandMarketSecExportQuery) query;
        BrandMarketSortSECQueryForm exportForm = new BrandMarketSortSECQueryForm();
        exportForm.setPageIndex(exportQuery.getPageIndex());
        exportForm.setPageSize(exportQuery.getPageSize());
        exportForm.setDateType(exportQuery.getDateType());
        exportForm.setSecIdCode(exportQuery.getSecIdCode());
        exportForm.setMinSellAccount(exportQuery.getMinSellAccount());
        exportForm.setMaxSellAccount(exportQuery.getMaxSellAccount());
        exportForm.setOrderColumn(exportQuery.getOrderColumn());
        exportForm.setOrderType(exportQuery.getOrderType());
        TableVO tableVO = brandMarketSortFacade.exportSECBrandMarketSortInfo(exportForm);
        return TableVoConvert.convert(tableVO);
    }
}
